<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        'use strict';
        function abs(x){
            if (typeof x !== 'number'){
                //手动抛出异常
                throw "not a number";
            }
            if (arguments.length>1){
                console.log(arguments[1]);
                alert(arguments[1]);
            }
            if (x>=0){
                return x;
            }else {
                return -x;
            }
        }
        //两种方法都可
        /*var abs = function (x){
            if (x>=0){
                return x;
            }else {
                return -x;
            }
        }*/
    </script>


</head>
<body>

</body>
</html>